<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="__PUBLIC__/echarts/echarts.min.js"></script>
    <link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="__PUBLIC__/font-awesome/css/font-awesome.min.css" media="all">
    <link rel="stylesheet" href="__CSS__/admin.css"  media="all">
    <script src="{$Think.config.httpFlag}{$Think.config.google_map_url}" async="async"></script>
</head>
<style>
    .poinumbtn{
        font-size: 12px;
        margin-left: 5px;
    }
    .seemap:hover{
        color: #666;
    }
    .layui-upload-img{
        width: 200px;
        margin-right: 10px;
        margin-bottom: 10px;
    }
</style>
<body>
<div class="layui-fluid main">

    <div class="right75" style="width: 100%;">
        <div style="margin: 10px  0">
            <div style="margin: 10px 0"><h2 id="poiname">{if $poiname}{$poiname}{/if}</h2><span class="color666" id="poieng_name">{if $poieng_name}{$poieng_name}{/if}</span></div>
            <div id="introduce" style="color: #9c9c9c">
                {if $introduce}{$introduce}{/if}
            </div>

            <div id="mobile">
                {if $mobile}<hr><strong>联系方式：</strong><span  class="colorf90">{$mobile}</span>{/if}
            </div>


            <div id="grade">
                {if $grade}<hr><strong>星级：</strong>
                <span class="colorf90"  >{$grade}</span>{/if}
            </div>


            <div id="ticket">
                {if $ticket}<hr> <strong>门票信息：</strong>
                <span class="colorf90"  >{$ticket}</span>{/if}
            </div>


            <div id="open_time">
                {if $open_time} <hr><strong>开放时间：</strong>
                <span  style="color: #9c9c9c">{$open_time}</span>{/if}
            </div>


            <div id="source">
                {if $source}<hr><strong>来源：</strong>
                <span  style="color: #9c9c9c">{$source}</span>{/if}
            </div>


            <div id="description">
                {if $description}<hr><strong>特别说明：</strong>
                <span  style="color: #9c9c9c">{$description}</span>{/if}
            </div>


            <div id="address">
                {if $address} <hr><strong>位置：</strong>
                <span  style="color: #9c9c9c">{$address}</span>{/if}
            </div>


            <div  id="nearspots">
                {if $nearspots}<hr><strong style="display: inline-block;margin-bottom: 10px">附近景点：</strong>
                <div style="color: #9c9c9c">

                    {volist name="nearspots" id="vo"}
                    <span style="display: inline-block;width: 100%;" class="seemap" codeid="{$vo[2]}">{$vo[0]}({$vo[1]}km)</span><hr class="layui-bg-gray">
                    {/volist}

                </div>{/if}
            </div>
        </div>
        <div id="map" style="height: 500px;width: 100%">

        </div>
        <hr>
        <div style="margin: 10px  0" id="thumb">

            {volist name="$thumb" id="vo"}
            {if !empty($vo)}
            <span class="uploadimgbox"><img class="layui-upload-img" src="{$vo}"></span>
            {/if}
            {/volist}
        </div>
    </div>
</div>
<script src="__PUBLIC__/layui/layui.js"></script>
<script src="__PUBLIC__/jquery/jquery.min.js"></script>
<script type="text/javascript">
    layui.use('layer', function(){
        var layer = layui.layer;
        $('.a_menu').click(function(){
            var url = $(this).attr('href');
            var a = 0;
            $.ajax({
                url:url
                ,async:false
                ,success:function(res){
                    if(res.code == 0) {
                        layer.msg(res.msg);
                        a = 1;
                    }
                }
            })
            if(a === 0) {
                layer.open({
                    type:2,
                    content:url,
                    area: ['900px', '700px'],
                    end:function(){
                        location.reload();
                    }
                });
            }
            return false;
        })

    });

    $('.delete').click(function(){
        var id = $(this).attr('data-id');
        layer.confirm('确定要删除?', function(index) {
            $.ajax({
                url:"{:url('admin/poi/delpoi')}",
                type:"post",
                data:{id:id},
                success:function(res) {
                    layer.msg(res.msg);
                    if(res.code == 1) {
                        setTimeout(function(){
                            location.href = res.url;
                        },1500)
                    }
                }
            })
        })
    })

    $("body").on("click",".seemap",function () {
        var id = $(this).attr('codeid');
        $.ajax({
            url:"{:url('admin/poi/seepoimap')}",
            data:{id:id},
            success:function(res) {
                if(res.code == 1) {
                    var data=res.data;



                    $("#poiname").html(data[0].name);
                    $("#poieng_name").html(data[0].eng_name);
                    $("#introduce").html(data[0].introduce);

                    // $("#description").html(data[0].description);

                    if(data[0].description!=""){
                        $("#description").html('<hr><strong>特别说明：</strong>' +
                            '<span style="color: #9c9c9c">'+data[0].description+'</span>');
                    }else{
                        $("#description").html("");
                    }

                    if(data[0].mobile!=""){
                        $("#mobile").html('<hr><strong>联系方式：</strong>' +
                            '                <span class="colorf90"  >'+data[0].mobile+'</span>');
                    }else{
                        $("#mobile").html("");
                    }

                    // $("#mobile").html(data[0].mobile);

                    if(data[0].ticket!=""&&data[0].ticket!=null){
                        $("#ticket").html('<hr><strong>门票信息：</strong>' +
                            '                <span class="colorf90"  >'+data[0].ticket+'</span>');
                    }else{
                        $("#ticket").html("");
                    }

                    // $("#ticket").html(data[0].ticket);

                    if(data[0].open_time!=""){
                        $("#open_time").html('<hr><strong>开放时间：</strong>' +
                            '<span style="color: #9c9c9c"  >'+data[0].open_time+'</span>');
                    }else{
                        $("#open_time").html("");
                    }


                    // $("#open_time").html(data[0].open_time);



                    // $("#source").html(data[0].source);

                    if(data[0].source!=""){
                        $("#source").html('<hr><strong>来源：</strong>' +
                            '<span  style="color: #9c9c9c">'+data[0].source+'</span>');
                    }else{
                        $("#source").html("");
                    }

                    if(data[0].grade!=0){
                        $("#grade").html('<hr><strong>星级：</strong>\n' +
                            '<span style="color: #9c9c9c" >'+data[0].grade+'</span>');
                    }else{
                        $("#grade").html("");
                    }

                    // $("#address").html(data[0].address);

                    if(data[0].address!=""){
                        $("#address").html('<hr><strong>位置：</strong>' +
                            '<span style="color: #9c9c9c" >'+data[0].address+'</span>');
                    }else{
                        $("#address").html("");
                    }


                    var nearspotsbox="";
                    for(var i=0 ;i<data[0].nearspots.length;i++){
                        nearspotsbox+=' <span  style="display: inline-block;width: 100%;" class="seemap" codeid="'+data[0].nearspots[i][2]+'">'+data[0].nearspots[i][0]+'('+data[0].nearspots[i][1]+'km)</span><hr class="layui-bg-gray">';
                    }

                    // $("#nearspots").html(nearspotsbox);
                    if(nearspotsbox!=""){
                        $("#nearspots").html('<hr><strong style="display: inline-block;margin-bottom: 10px">附近景点：</strong><div style="color: #9c9c9c">' + nearspotsbox+'</div></span>');
                    }else{
                        $("#nearspots").html("");
                    }

                    var thumbbox="";
                    var thumbs=data[0].thumb.split(",");
                    for (var i=0;i<thumbs.length;i++){
                        if(thumbs[i]){
                            thumbbox+='<span class="uploadimgbox"><img class="layui-upload-img" src="'+thumbs[i]+'"></span>'
                        }
                    }
                    $("#thumb").html(thumbbox);
                    initialize(data[0].lat,data[0].lng);
                }else{
                    layer.msg(res.msg);
                }
            }
        })
    })

</script>
<script type="text/javascript">
    //地图功能
    var geocoder;
    var map2;
    var marker=new google.maps.Marker();
    function initialize(lat,lng) {
        geocoder = new google.maps.Geocoder();
        var myOptions = {
            zoom : 10,//缩放比例
            center:new google.maps.LatLng(lat,lng),
            mapTypeId : google.maps.MapTypeId.ROADMAP
        };
        map2 = new google.maps.Map(document.getElementById("map"),
            myOptions);
        marker.setMap(null);
        marker = new google.maps.Marker({
            map : map2,
            position :new google.maps.LatLng(lat,lng),
            //坐标动画效果
            animation : google.maps.Animation.DROP
        });
        marker.setMap(map2);
    }

    initialize({$latlng[0]},{$latlng[1]});

</script>
</body>
</html>
